package com.fitbet.admin.dao;

import java.util.List;

import com.demo2do.core.persistence.annotation.Dao;
import com.demo2do.core.persistence.annotation.Limit;
import com.demo2do.core.persistence.annotation.Query;
import com.demo2do.core.persistence.annotation.Variable;
import com.fitbet.entity.bet.Bet;
import com.fitbet.entity.bet.BetStatus;
import com.fitbet.entity.bet.UserBet;

/**
 * @author xiaoHU
 *
 */
@Dao("hibernate")
public interface BetDao {

    /**
     * @param status
     */
    @Query("SELECT COUNT(*) FROM Bet  WHERE status = :status AND disabled = false")
    public int count(@Variable("status") BetStatus status);

    /**
     * @param status
     * @param beginIndex
     * @param maxResult
     * @return
     */
    @Limit
    @Query("FROM Bet WHERE status = :status AND disabled = false")
    public List<Bet> list(@Variable("status") BetStatus status, @Variable("beginIndex") int beginIndex,@Variable("maxResult") int maxResult); 

    /**
     * 
     * @param id
     * @return
     */
    @Query("FROM UserBet WHERE bet.id =:id")
    public List<UserBet> listById(@Variable("id") Long id);
    
    /**
     * 
     * @param betId
     * @return
     */
    @Query("FRO UserBet WHERE bet.id =:betId AND success = true")
    public List<UserBet> listByIdAndSuccess(@Variable() Long betId);
    
}
